﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Diagnostics;
using System.IO;


public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (HttpContext.Current.Request.QueryString["start"] != null)
        {
            var appPath = Path.Combine(
                Request.PhysicalApplicationPath,
                "SiteNoteInstall.package");

            var installerProcessStartInfo = new ProcessStartInfo(appPath);
            installerProcessStartInfo.CreateNoWindow = true;
            installerProcessStartInfo.WindowStyle = ProcessWindowStyle.Hidden;
            installerProcessStartInfo.UseShellExecute = false;
            //installerProcessStartInfo.RedirectStandardError = true;
            installerProcessStartInfo.RedirectStandardOutput = true;
            installerProcessStartInfo.Arguments = "x -y -o"
                + Request.PhysicalApplicationPath;

            var installerProcess = new Process();
            installerProcess.StartInfo = installerProcessStartInfo;
            installerProcess.Start();
            //var error = installerProcess.StandardError.ReadToEnd();
            var output = installerProcess.StandardOutput.ReadToEnd();
            installerProcess.WaitForExit();

            HttpContext.Current.Response.Redirect("setup.aspx");
        }
    }
}

